import { Component ,Input ,Output,EventEmitter,} from '@angular/core';
import { Router } from '@angular/router';


/**
 * 后台管理评论页标签编辑组件
 * @example
 * 示例：评论管理编辑页面，用该组件渲染出评论用户数据列表
 * 输入属性：comment object类型
 * 输出属性：delete 向父组件deleteVideoComment($event)方法传参
 * 输出属性：restore 向父组件deleteVideoComment($event,true)方法传参
 *   <ng-comment-item *ngFor="let comment of VideoCommentList" 
 *      [comment]="comment"
 *      (delete)="deleteVideoComment($event)"
 *      (restore)="deleteVideoComment($event,true)"
 *    >
 *   </ng-comment-item>
 */
@Component({
  selector: 'ng-comment-item',
  templateUrl: './comment-item.component.html',
  styleUrls: ['./comment-item.component.scss']
})
export class CommentItemComponent {

   /**
   * 从父组件传入绑定的对象数据值
   * @type Object
   * @example
   * [comment]="comment"
   */
  @Input("comment")
  comment:any={}


  @Output("edit")
  _edit:EventEmitter<any> = new EventEmitter()

  /**
   * 向父组件传参
   * @example
   * (delete)="deleteVideoComment($event)"
   * (restore)="deleteVideoComment($event,true)"
   */

  @Output("delete")
  _delete:EventEmitter<any> = new EventEmitter()

  @Output("restore")
  _restore:EventEmitter<any> = new EventEmitter()



  constructor(private router:Router){}

  delete(){
    this._delete.emit(this.comment)
  }

  /**
   * 跳转到/admin-bvideo/commentedit页面
   * 并传出comment的objectId属性到对应组件
   * @example
   * (click)="edit()" 
   */
  edit(){
    this.router.navigate(["/admin-bvideo/commentedit"],{
      queryParams:{
        id:this.comment.objectId
      }
    })
    // this._edit.emit(this.comment)
  }


  restore(){
    this._restore.emit(this.comment)
  }

}
